// all these tables are used in many functions as
// brute force process 
// canonical process (especially canonical on pattenrs)
// UAs search
#include "sk_typ0.h"
extern byte Tblfirst0_8[512] ;
extern byte BitCount[512] ; 	// number of bits (1)  in a 9 bits field


struct BF3{// 3 x 27 bit fileds for the 3 bands 
	unsigned int  bf[3];
	inline void Init(){bf[0]=bf[1]=bf[2]=0;}
	BF3 operator |(BF3 & e) {BF3 w;	w.bf[0]  =  bf[0] | e.bf[0];  w.bf[1] = bf[1] | e.bf[1];	
									w.bf[2]  =  bf[2] | e.bf[2];	return w;	}
	BF3 operator &(BF3 & e) {BF3 w;	w.bf[0]  =  bf[0] & e.bf[0];  w.bf[1] = bf[1] & e.bf[1];	
									w.bf[2]  =  bf[2] & e.bf[2];	return w;	}
	BF3 operator ^ (BF3 & e) {BF3 w;	w.bf[0]  =  bf[0] ^ e.bf[0];  w.bf[1] = bf[1] ^ e.bf[1];	
									w.bf[2]  =  bf[2] ^ e.bf[2];	return w;	}
	void operator |=(BF3 & e) {  bf[0] |= e.bf[0];   bf[1] |= e.bf[1]; bf[2] |= e.bf[2];}
	void operator &=(BF3 & e) {  bf[0] &= e.bf[0];   bf[1] &= e.bf[1]; bf[2] &= e.bf[2];}
	void operator ^=(BF3 & e) {  bf[0] ^= e.bf[0];   bf[1] ^= e.bf[1]; bf[2] ^= e.bf[2];}
	BF3 operator ~ () {BF3 w;w.bf[0]=bf[0]^ BIT_SET_27;
							w.bf[1]=bf[1]^ BIT_SET_27;
							w.bf[2]=bf[2]^ BIT_SET_27;  return w;}
	int operator == (BF3 & e) {return(bf[0]==e.bf[0] && bf[1]==e.bf[1] && bf[2]==e.bf[2]);}
	int operator != (BF3 & e) {return(bf[0]!=e.bf[0] || bf[1]!=e.bf[1] || bf[2]!=e.bf[2]);}
	inline int Disjoint(BF3 & e) {if((bf[0]&e.bf[0]) || (bf[1]&e.bf[1]) || (bf[2]&e.bf[2]))
							return 0; else return 1;}
	BF3 operator - (BF3 & e) {BF3 w;	w.bf[0]  =  bf[0] ^(bf[0] & e.bf[0]);  
	                                w.bf[1] = bf[1] ^(bf[1] &  e.bf[1]);	
									w.bf[2]  =  bf[2] ^ (bf[2] & e.bf[2]);	return w;	}
	int IsNotIncluded(BF3 & e) {return( bf[0] ^(bf[0] & e.bf[0]) ||   bf[1] ^(bf[1] &  e.bf[1]) ||
									 bf[2] ^ (bf[2] & e.bf[2])) ;	}
	inline int IsFull(){return (bf[0]==BIT_SET_27 && bf[1]==BIT_SET_27 && bf[2]==BIT_SET_27);}

	inline int Overlay(BF3 & e) {return !Disjoint(e);}
	inline void Set(int x){		if(x<27) bf[0]|= (1<<x);
								else if(x<54) bf[1] |= (1<<(x-27));
								else bf[2] |= (1<<(x-54));	}
	inline int Is(int x){		if(x<27) return (bf[0]& (1<<x));
								else if(x<54) return( bf[1] & (1<<(x-27)));
								else return (bf[2] & (1<<(x-54)));	}
	inline void Clear(int x){	if(x<27) bf[0]&= ~(1<<x);
								else if(x<54) bf[1] &= ~(1<<(x-27));
								else bf[2] &= ~(1<<(x-54));	}
	char * String(char zout[82]);
	int String(int * tr);
};

class BF16 {
public:
	word f;
	// constructors
	BF16() {f = 0;	}               
	BF16(int x) {f = 0x1ff;	}               
	inline int On(int ch) const {	return ((f & (1 << ch)));	}		
	inline int Off(int ch) const {	return (!(f & (1 << ch)));	}	
	inline void Set(word ch) {f |= (1 << ch);	}	
	inline void Clear(word ch) {	f &= ~(1 << ch);	}
	inline BF16 operator &(BF16 & e) const {		BF16 w;		w.f = f & e.f;		return w;	}
	inline BF16 operator |(BF16 & e) {		BF16 w;		w.f = f | e.f;		return w;	}
	inline BF16 operator ^(BF16 & e) {		BF16 w;		w.f = f ^ e.f;		return w;	}
	inline BF16 operator -(BF16 & e) {		BF16 w;		w.f = f ^ (e.f & f);		return w;	}
	inline int  operator ==(BF16 & e) {		return(e.f == f);	}
	inline void operator &=(BF16 & e) {	f &= e.f;	}
	inline void operator |=(BF16 & e) {	f |= e.f;	}
	inline void operator ^=(BF16 & e) {	f ^= e.f;	}
	inline void operator -=(BF16 & e) {	f ^= (f & e.f);	}
	inline int  First0_8() {return Tblfirst0_8[f];	}
	inline word bitCount() {	return BitCount[f];	}
//	word String(word * rr);
//	char * StringOut(char * out);

}; // BF16



